<?php
namespace control;
/*
*外出申请类
*/

class workOutClass extends adIndexClass
{
    private const table = 'work_out';
    private const page = 'workOut';
    private const title = '外出申请';
    public array $stateOption = ['草稿', '审核中', '已通过', '审核成果', '成果确认'];

    /*行政人事-外出记录-查询条件*/
    public function home()
    {
        $html = '';
        if ($this->power(self::page, "seeAll")) {
            $html .= selectMultiple(array("name" => "stid", "title" => L('clock.table.shen_qing_ren'), "table" => "staff", 'sqlField' => 'name', 'sqlId' => 'stid'));
        }
        $html .=
            text(array('name' => 'orderNo', 'title' => L('clock.table.dan_ju_bian_hao'))) .
            text(array('name' => 'text', 'title' => L('clock.table.wai_chu_shi_you'))) .
            text(array('name' => 'deptName', 'title' => L('clock.table.sqrbm'))) .
            text(array("name" => "createTime",'class'=>'width200', 'laydate' => ['range' => '~'], "title" => L('clock.table.sjwcsj') . "-" . L('clock.table.sjwcsj'))) .
            select(array("name" => "state", "title" => L('clock.table.zhuang_tai'), "option" => $this->stateOption));
        //返回
        return $this->homeFun($this->search($html));
    }

    /*行政人事-外出记录-查询结果*/
    public function homeSearch()
    {
        //全等查询数组
        $equal = array(
            "stid" => $this->post('stid'),//员工
            "state" => $this->post('state'),//办理状态（待处理/已完成）
        );
        //like查询数组
        $like = array(
            "text" => $this->post('text'),//加班事由
            "orderNo" => $this->post('orderNo'),//单据编号
            "deptName" => $this->post('deptName'),//申请人部门
        );
        //初始化
        $and = "";
        if ($this->post('createTime')) {
            $and .= self::timeComparison($this->post('createTime'), field: 'timeStart');
        }
        //如果没有查看所有员工请假记录的权限
        if (!$this->power("workOut", "seeAll")) {
            $and .= " and stid = '" . $this->control['stid'] . "' ";
        }
        //获取查询结果
        $where = search(array("like" => $like, "=" => $equal)) . $and;
        $page = $this->page(array("table" => "work_out", "where" => $where, "order" => "timeStart desc"));
        //获取表头
        $checkAll = $this->checkAll("listForm", "workOutId");
        $tr[] = array($checkAll, L('clock.table.dan_ju_bian_hao'), L('clock.table.shen_qing_ren'), L('clock.table.yjwcsj'), L('clock.table.wai_chu_shi_you'), L('clock.table.sjwcsj'), L('clock.table.sqrbm'), L('clock.table.zhuang_tai'));
        $url = root . "control/adIndex.html?cla=" . $this->get('cla') . "";
        //获取记录
        foreach ($page['array'] as $array) {
            //列表控件
            $dominate = array(
                "box" => array("name" => "workOutId", "value" => $array['id']),
                "detail" => array("title" => L('clock.table.wcxq'), "click" => "newIframe('" . L('clock.table.wcxq') . "','" . $url . "&fun=detail&id=" . $array['id'] . "')"),
            );
            //外出对象
            $expectTime = $array['expectTimeStart'] . "-" . $array['expectTimeEnd'];
            $resultTime = $array['timeStart'] . "-" . $array['timeEnd'];
            $text = zishu($array['text'], 16);
            //返回本行
            $tr[] = array($this->dominate($dominate), $array['orderNo'], self::findStaff($array['stid']), $expectTime, $text, $resultTime, $array['deptName'], $array['state']);
        }
        //控件
        $button = "";
//		if($this->power(self::page,"edit")){
//			$button .= "<span onclick=\"newIframe('".self::title."详情','" . $url . "&fun=edit')\" class='spanButton'>外出申请</span>";
//		}
        //返回
        $json['html'] = $page['hint'] . $button . "<form name='listForm'>" . space . $this->tableMany(array("tr" => $tr)) . "</form>" . $page['button'] . clear;
        return json_encode($json, 320);
    }

    /**
     * 编辑
     * @return string
     */
    public function edit(): string
    {
        $id = $this->get('id') ?: suiji();
        $info = query(self::table, " id = '" . $id . "' ");
        //表单
        $data['html'] = $this->layerEdit([
            "table" => [
                array(
                    must . L('clock.table.yjwcsj') . "：" =>
                        text(array("name" => "chooseTime", "class" => "width300", "laydate" => array("type" => "datetime", 'range' => '~'), "value" => $info['id'] ? ($info['expectTimeStart'] . ' ~ ' . $info['expectTimeEnd']) : (date("Y-m-d 00:00:00") . ' ~ ' . date("Y-m-d 23:59:59")))),
                ),
                array(
                    must . L('clock.table.wai_chu_shi_you') . "：" => textarea(array("name" => "text", "value" => $info['text'])),
                ),
            ],
            'hidden' => hidden(array('name' => 'id', 'value' => $info['id'] ?: $id)),
            'button' => "<button class=\"button left-bottom\" onclick=\"subForm('{$this->get('cla')}EditForm',root+'control/adIndex.html?cla=" . self::page . "&fun=editEdit')\">" . L('clock.table.bao_cun') . "</button>",
        ]);
        //返回
        return $this->tab($data);

    }

    /*编辑*/
    public function editEdit()
    {
        $id = $this->post('id') ?: self::getId();
        $timeArr = $this->post('chooseTime') ? explode(' ~ ', $this->post('chooseTime')) : [];
        //赋值
        $field = array(
            "expectTimeStart" => $timeArr[0],
            "expectTimeEnd" => $timeArr[1],
            "text" => $this->post('text'),//备注
            "updateTime" => date("Y-m-d H:i:s"),//更新时间
        );
        $annotation = [
            "expectTimeStart" => L('clock.table.yjwcsj'),
            "expectTimeEnd" => L('clock.table.yjwcsj'),
            "text" => L('clock.table.wai_chu_shi_you'),
        ];
        $rules = [
            'expectTimeStart' => 'required',
            'expectTimeEnd' => 'required',
            'text' => 'required',
        ];
        // 校验是否符合规则
        $vt = new \verify();
        $result = $vt->setAliases($annotation)->validate($field, $rules)->isOk();
        if ($result === false) {
            $json['warn'] = $vt->getErrs()[0];  // 多个规则提示最前面一条
            goto resp;
        }
        $info = query(self::table, " id = '" . $id . "' ");
        //判断
        if (!$this->power(self::page, "edit")) {
            $json['warn'] = L('clock.table.zxbz');
        } elseif ($field['expectTimeStart'] > $field['expectTimeEnd']) {
            $json['warn'] = L('clock.table.jssjbdxykssj');
        } elseif (sqlNum("work_out", " stid = '" . $this->control['stid'] . "' and timeStart < '$field[expectTimeEnd]' and timeEnd > '$field[expectTimeStart]' and id != '" . $id . "' ") > 0) {
            $json['warn'] = L('clock.table.yqtsjwcsjczjc');
        } else{
            if (empty($info['id'])) {
                $userNo = codeTemplateClass::generateCode(self::page, [
                    'prefix' => 'WCSQ' . date('Ymd'),
                    'table' => self::table,
                    'field' => 'orderNo',
                    'where' => '',
                ], $field);
                $department = query('department', " id = '{$this->controlJob['departmentId']}'");
                $field = array_merge($field, array("id" => $id, 'orderNo' => $userNo, 'state' => '草稿', 'deptName' => $department['name'], 'stid' => $this->control['stid'], "time" => date("Y-m-d H:i:s")));
                $json['warn'] = insert(array("table" => self::table, "field" => $field));
            } else {
                $userNo = $info['orderNo'];
                $json['warn'] = update(array("table" => self::table, "field" => $field, "where" => "id = '$info[id]'"));
            }
            if (in_array($json['warn'], array("新增成功", "更新成功"))) {
                //添加日志
                $text = str_replace(['{{staffName}}', '{{orderNo}}', '{{id}}'], [$this->control['name'], $userNo, $id], L('clock.table.out_edit_text'));
                $this->logText(array("type" => self::page, "text" => $text));
                //返回
                $_SESSION['warn'] = $json['warn'];
                $json['warn'] = 2;
            }
        }

        $json['href'] = root . "control/adIndex.html?cla=" . self::page . "&fun=detail&id=" . $id;
        resp:
        return json_encode($json, 320);
    }


    /**
     * 审核按钮
     * @param $info
     * @return array
     */
    public function auditButton($info): array
    {
        if (in_array($info['state'], ['已通过', '审核中'])) {
            $name = '外出申请';
        } else {
            $name = '外出成果审核';
        }
        $button = [];
        if (($info['state'] == '草稿' && $info['stid'] == self::$stid) || ($info['state'] == '审核中' && auditClass::auditFlag(self::table, $info['id'], 'selfChoose'))) {
            $button[] = [
                "name" => L('clock.table.ti_jiao_shen_pi'),
                "type" => "弹出层",
                "cla" => 'audit',
                "fun" => "operate",
                'style' => 'li-btn-blue-bg',
                "post" => ["act" => 'start', "id" => $info['id'], 'body' => self::encryptDecrypt(json_encode([
                    'name' => '外出申请',
                    'table' => self::table,
                    'process' => [
                        // 预览函数
                        'detail' => [
                            'cla' => $this->get('cla'),
                            'fun' => 'detail'
                        ],

                        //执行发起时验证函数
                        'before' => [
                            'cla' => $this->get('cla'),
                            'fun' => ''
                        ],
                        //完成发起后执行函数
                        'after' => [
                            'cla' => $this->get('cla'),
                            'fun' => ''
                        ],
                    ],
                ], 320))],
            ];
        }
// 审批并判断是否有权限
        if ($info['state'] == '审核中' && auditClass::auditFlag(self::table, $info['id'], 'approver', $name)) {
            $button[] = [
                "name" => L('clock.table.tjspr'),
                "type" => "弹出层",
                "cla" => 'audit',
                "fun" => "operate",
                "post" => ["act" => 'addApprover', "id" => $info['id'], 'body' => self::encryptDecrypt(json_encode([
                    'name' => $name,
                    'table' => self::table
                ], 320))],
            ];
            $button[] = [
                "name" => L('clock.table.zhuan_jiao'),
                "type" => "弹出层",
                "cla" => 'audit',
                "fun" => "operate",
                "post" => ["act" => 'transfer', "id" => $info['id'], 'body' => self::encryptDecrypt(json_encode([
                    'name' => $name,
                    'table' => self::table
                ], 320))],
            ];
            $button[] = [
                "name" => L('clock.table.shen_pi'),
                "type" => "弹出层",
                "cla" => 'audit',
                "fun" => "operate",
                // 以下参数固定格式
                "post" => ["act" => 'approval', "id" => $info['id'], 'body' => self::encryptDecrypt(json_encode([
                    'name' => $name,
                    'table' => self::table,
                    // 当前状态
                    'state' => $info['state'],
                    // 变更
                    'field' => ['state'],   //变更字段 可多个
                    'value' => [
                        'state' => ['草稿', '已通过'],
                    ],
                    // 审核时回调
                    'process' => [
                        //执行首次审核时验证
                        'before' => [
                            'cla' => $this->get('cla'),
                            'fun' => ''
                        ],
                        //执行末次审核后处理
                        'after' => [
                            'cla' => $this->get('cla'),
                            'fun' => ''
                        ],
                    ],
                ], 320))],
                'style' => 'li-btn-blue-bg',
            ];
        }

        if (($info['state'] == '已通过' && $info['stid'] == self::$stid) || auditClass::auditFlag(self::table, $info['id'], 'selfChoose')) {
            $button[] = [
                "name" => L('clock.table.ti_jiao_shen_pi'),
                "type" => "弹出层",
                "cla" => 'audit',
                "fun" => "operate",
                'style' => 'li-btn-blue-bg',
                "post" => ["act" => 'start', "id" => $info['id'], 'body' => self::encryptDecrypt(json_encode([
                    'name' => '外出成果审核',
                    'table' => self::table,
                    'process' => [
                        // 提交后状态
                        'state' => '审核成果',
                        // 预览函数
                        'detail' => [
                            'cla' => $this->get('cla'),
                            'fun' => 'detail'
                        ],
                        //执行发起时验证函数
                        'before' => [
                            'cla' => $this->get('cla'),
                            'fun' => ''
                        ],
                        //完成发起后执行函数
                        'after' => [
                            'cla' => $this->get('cla'),
                            'fun' => ''
                        ],
                    ],
                ], 320))],
            ];
        }
// 审批并判断是否有权限
        if ($info['state'] == '审核成果' && auditClass::auditFlag(self::table, $info['id'], 'approver', $name)) {
            $button[] = [
                "name" => L('clock.table.tjspr'),
                "type" => "弹出层",
                "cla" => 'audit',
                "fun" => "operate",
                "post" => ["act" => 'addApprover', "id" => $info['id'], 'body' => self::encryptDecrypt(json_encode([
                    'name' => $name,
                    'table' => self::table
                ], 320))],
            ];
            $button[] = [
                "name" => L('clock.table.zhuan_jiao'),
                "type" => "弹出层",
                "cla" => 'audit',
                "fun" => "operate",
                "post" => ["act" => 'transfer', "id" => $info['id'], 'body' => self::encryptDecrypt(json_encode([
                    'name' => $name,
                    'table' => self::table
                ], 320))],
            ];
            $button[] = [
                "name" => L('clock.table.shen_pi'),
                "type" => "弹出层",
                "cla" => 'audit',
                "fun" => "operate",
                // 以下参数固定格式
                "post" => ["act" => 'approval', "id" => $info['id'], 'body' => self::encryptDecrypt(json_encode([
                    'name' => $name,
                    'table' => self::table,
                    // 当前状态
                    'state' => $info['state'],
                    // 变更
                    'field' => ['state'],   //变更字段 可多个
                    'value' => [
                        'state' => ['已通过', '成果确认'],
                    ],
                    // 审核时回调
                    'process' => [
                        //执行首次审核时验证
                        'before' => [
                            'cla' => $this->get('cla'),
                            'fun' => ''
                        ],
                        //执行末次审核后处理
                        'after' => [
                            'cla' => $this->get('cla'),
                            'fun' => ''
                        ],
                    ],
                ], 320))],
                'style' => 'li-btn-blue-bg',
            ];
        }

        // 撤销审批
        if (auditClass::auditFlag(self::table, $info['id'], 'cancel', $name) && $info['state'] != '草稿') {
            $button[] = [
                "name" => L('clock.table.cxsp'),
                "type" => "弹出层",
                "cla" => 'audit',
                "fun" => "operate",
                "post" => ["act" => 'cancel', "id" => $info['id'], 'body' => self::encryptDecrypt(json_encode([
                    'name' => $name,
                    'table' => self::table,
                    // 当前状态
                    'state' => $info['state'],
                    // 变更
                    'field' => ['state'],   //变更字段 可多个
                    'value' => [
                        'state' => ['草稿'],
                    ],
                    'process' => [
                        //完成发起后执行函数
                        'after' => [
                            'cla' => $this->get('cla'),
                            'fun' => ''
                        ],
                    ],
                ], 320))],
            ];
        }


        return $button;
    }


    /*外出详情*/
    public function detail(): string
    {
        //定义参数
        if (empty($this->get('id'))) {
            $html = L('clock.table.wzdcjl');
        } else {
            $info = query(self::table, " id = '" . $this->get('id') . "' ");
            if (empty($info['id'])) {
                $html = L('clock.table.wzdcjl');
            } else {
                $obj = new fileUploadClass();
                $data = array("id" => $info['id']);
                $button = [];
                if ($this->power(self::page, "edit") && $info['state'] == '草稿') {
                    //按钮
                    $button[] = [
                        "name" => L('clock.table.bian_ji'),
                        "type" => "顶部页卡",
                        "title" => L('clock.table.bian_ji'),
                        "url" => $this->root . 'control/adIndex.html?cla=' . $this->get('cla') . '&fun=edit&id=' . $info['id'],
                    ];
                }
                if ($this->power(self::page, "del") && $info['state'] == '草稿') {
                    //按钮
                    $button[] = [
                        "name" => L('clock.table.shan_chu'),
                        "type" => "弹出层",
                        "cla" => $this->get('cla'),
                        "fun" => "operate",
                        "post" => ["act" => 'del', "id" => $info['id']],
                    ];
                }
                if ($info['state'] == '已通过' && $info['stid'] == self::$stid) {
                    //按钮
                    $button[] = [
                        "name" => L('clock.table.bjcg'),
                        "type" => "点击事件",
                        "title" => L('clock.table.bjcg'),
                        "fun" => "layer('" . self::page . "','result',{id:'" . $info['id'] . "'})",
                    ];
                }
                $audit = query('audit', " targetId = '$info[id]'");
                //审核按钮
                $button = array_merge($button, $this->auditButton($info));

                $field = array(
                    "button" => $button,
                    array(
                        array(
                            L('clock.table.yjwcsj') => $info['expectTimeStart'] . '至' . $info['expectTimeEnd'],
                        ),
                        array(
                            L('clock.table.wai_chu_shi_you') => $info['text'],
                        ),
                    ),
                );
                if (in_array($info['state'], ['已通过', '审核成果', '成果确认'])) {
                    $field = array_merge($field, [
                        L('clock.table.out_result') => array(
                            array(
                                L('clock.table.sjwcsj') => strtotime($info['timeStart']) > 0 ? ($info['timeStart'] . '至' . $info['timeEnd']) : '',
                            ),
                            array(
                                L('clock.table.out_result') => $info['result'],
                            ),
                            array(
                                $obj->showFile($info['id'], '外出成果')
                            )
                        )
                    ]);
                }
                /********系统信息*******/
                $field = array_merge($field, [
                    L('clock.table.xi_tong_xin_xi') => array(
                        array(
                            L('clock.table.dan_ju_bian_hao') => $info['orderNo'],
                            L('clock.table.sqrbm') => $info['deptName'],
                            L('clock.table.shen_qing_ren') => self::findStaff($info['stid']),
                        ),
                        array(
                            L('clock.table.cjsj') => $info['time'],
                            L('clock.table.tjsj') => self::null($audit['commitTime']),
                            L('clock.table.zhuang_tai') => $info['state'],
                        ),
                    ),
                    L('clock.table.liu_cheng') => array(
                        array(
                            auditClass::auditRecord(self::table, $info['id'])
                        )
                    ),
                ]);
                $data['html'] = $this->tableShow($field);

                $html = $this->tab($data);
            }
        }
        return $html;
    }

    /*提交外出成果报告-弹出层*/
    public function result()
    {
        //准备数据
        $info = query("work_out", " id = '" . $this->post('id') . "' ");
        //拼接表单
        $html = $this->layerEdit([
            "table" => [
                array(
                    must . L('clock.table.sjwcsj') . "：" =>
                        text(array("name" => "chooseTime", 'class' => 'width300', "laydate" => array("type" => "datetime", 'range' => '~'), "value" => $info['id'] ? ($info['timeStart'] . ' ~ ' . $info['timeEnd']) : '')),
                ),
                array(
                    must . L('clock.table.out_result') . "：" => textarea(array("name" => "result", "value" => $info['result'])),
                ),
                array(
                    L('clock.table.fu_jian') => fileUploadClass::addFileComponent($info['id'], '外出成果', self::page, self::page . 'ResultForm'),
                )
            ],
        ]);
        //返回
        return $this->layer(array("title" => L('clock.table.tjwccgbg'), "height" => 582, "width" => 1100, "html" => $html));
    }

    /*提交外出成果报告-异步处理*/
    public function resultEdit()
    {
        $id = $this->post('id');
        //附件
        $fileIdArr = $this->post('fileId');
        $timeArr = $this->post('chooseTime') ? explode(' ~ ', $this->post('chooseTime')) : [];
        //赋值
        $field = array(
            "timeStart" => $timeArr[0],
            "timeEnd" => $timeArr[1],
            "result" => $this->post('result'),//备注
            "updateTime" => date("Y-m-d H:i:s"),//更新时间
        );
        $annotation = [
            "timeStart" => L('clock.table.sjwcsj'),
            "timeEnd" => L('clock.table.sjwcsj'),
            "result" => L('clock.table.out_result'),
        ];
        $rules = [
            'timeStart' => 'required',
            'timeEnd' => 'required',
            'result' => 'required',
        ];
        // 校验是否符合规则
        $vt = new \verify();
        $result = $vt->setAliases($annotation)->validate($field, $rules)->isOk();
        if ($result === false) {
            $json['warn'] = $vt->getErrs()[0];  // 多个规则提示最前面一条
            goto resp;
        }
        $info = query(self::table, " id = '" . $id . "' ");
        //判断
        if (!$this->power(self::page, "edit")) {
            $json['warn'] = L('clock.table.zxbz');
        } elseif (strtotime($field['timeEnd']) < strtotime($field['timeStart'])) {
            $json['warn'] = L('clock.table.jssjbdxykssj');
        } elseif (sqlNum("work_out", " stid = '" . $this->control['stid'] . "' and timeStart < '$field[timeEnd]' and timeEnd > '$field[timeStart]' and id != '" . $id . "' ") > 0) {
            $json['warn'] = L('clock.table.yqtsjwcsjczjc');
        } elseif (empty($info['id'])) {
            $json['warn'] = L('clock.table.wzdcwcjl');
        } else {
            $json['warn'] = update(array("table" => self::table, "field" => $field, "where" => "id = '$info[id]'"));
        }
        if (in_array($json['warn'], array("新增成功", "更新成功"))) {
            //添加主表ID到附件表
            if (is_array($fileIdArr)) {
                update(array('table' => 'file', 'field' => ['targetId' => $id], 'where' => " targetId = '' and id in ('" . implode("','", $fileIdArr) . "')"));
            }
            //添加日志
            $text =str_replace(['{{staffName}}', '{{orderNo}}', '{{id}}'], [$this->control['name'], $info['orderNo'], $id], L('clock.table.out_edit_result'));
            $this->logText(array("type" => self::page, "text" => $text));
            //返回
            $_SESSION['warn'] = $json['warn'];
            $json['warn'] = 2;
        }
        $json['href'] = root . "control/adIndex.html?cla=" . self::page . "&fun=detail&id=" . $id;
        resp:
        return json_encode($json, 320);
    }

    /*行政人事-外出申请-批量删除*/
    public function delete()
    {
        $array = $this->post('workOutId') ?? $this->post('id');
        if (!$this->power(self::page, "del")) {
            $json['warn'] = L('clock.table.nmzscwcsqdzx');
        } elseif (empty($array)) {
            $json['warn'] = L('clock.table.nytjldmzxzn');
        } else {
            $array = is_array($array) ? $array : [$array];
            $text = "";
            $x = 0;
            foreach ($array as $id) {
                //查询
                $workOut = query("work_out", " id = '$id' ");
                if (!in_array($workOut['state'], array("草稿", "已通过"))) {
                    $warn = L('clock.table.out_warn');
                } elseif (!$this->power(self::page,'seeAll') && $workOut['stid'] != $this->control['stid']) {
                    $warn = L('clock.table.self_outApply');
                } else {
                    //删除audit表记录
                    delete(array('table' => 'audit', 'where' => "targetId = '$id'"));
                    //删除待办事项
                    delete(array("table" => "backlog", "where" => " typeId = '$id' "));
                    //删除审批记录
                    delete(array("table" => "auditing_follow", "where" => " typeId = '$id' "));
                    $all = find(array('table' => 'file', 'where' => "targetId = '$id'"));
                    foreach ($all['array'] as $val) {
                        fileDelete($val['src']);
                        delete(array("table" => 'file', "where" => " id = '$val[id]' "));
                    }
                    //删除消息提醒
                    delete(array("table" => "message", "where" => " typeId = '$id' "));
                    //删除外出申请
                    delete(array("table" => "work_out", "where" => " id = '$id' "));
                    //返回信息
                    $warn = L('clock.table.del_warn');
                    $x++;
                }
                $text .= str_replace(['{{name}}', '{{orderNo}}', '{{id}}', '{{startTime}}', '{{endTime}}'], [self::findStaff($workOut['stid']), $workOut['orderNo'],$workOut['id'], $workOut['expectTimeStart'], $workOut['expectTimeEnd']], L('clock.table.out_del_text')) . $warn . "\n";
            }
            //添加日志
            $text = str_replace(['{{staffName}}'], [$this->control['name']], L('clock.table.out_del_log')) . "<br>" . $text;
            $this->logText(array("type" => "workOut", "text" => $text));
            //返回信息
            $_SESSION['warn'] = str_replace(['{{x}}'], [$x], L('clock.table.out_del_warn'));
            $json['warn'] = 2;
            $json['href'] = root . "control/adIndex.html?cla=" . $this->get('cla') . "&fun=home";
        }
        return json_encode($json, 320);
    }

    // 操作中转
    public function operate()
    {
        $act = $this->post('act') ?? '';
        $pwd = false; // 需要密码
        switch ($act) {
            default:
                $act = 'del';
                $msg = L('clock.table.out_del_title');
                $title = self::page . 'Delete';
                $function = 'delete';
                $form = self::page . 'OperateForm, listForm';
                $power = '';
                break;
        }
        if (!$this->power(self::page, $act)) {
            $_SESSION['warn'] = str_replace(['{{msg}}'], [$msg], L('jon.other.permission_warn'));
            $json = [
                'warn' => 2,
                'href' => root . 'control/adIndex.html?cla=' . $this->get('cla') . '&fun=home',
            ];
        } else {
            return $this->confirm([
                'title' => $title,
                'function' => $function,
                'form' => $form,
                'power' => $power,
                'pwd' => $pwd,
            ]);
        }

        resp:
        return json_encode($json, 320);
    }


}
